<template>
  <div class="container">
    <headerBar :title="local.purchaseWarehousingDetails" @changeLan="changeLan"></headerBar>
    <div class="all" style="margin-bottom: 100rpx;" :style="{paddingTop: pdt+'px'}">
      <div class="top">
        <div class="select-panel">
          <div class="record-Number">
            <div class="a">{{local.stockInNo}}：{{objEdit.code}}</div>
            <div class="b">{{objEdit.createTime}}</div>
          </div>
          <div class="panel-supplier">
            <div class="name">
              <span style="color: red;">*</span>
              {{local.supplier}}：
            </div>
            <div class="page" style="border-bottom: 2rpx solid;">
              <picker
                class="weui-btn"
                @change="PickerChange"
                disabled
                :range="array"
                :index="indexPicker"
                :range-key="'supplierName'"
              >
                <input
                  type="default"
                  disabled
                  v-model="objEdit.supplierName"
                  :placeholder="local.option"
                />
                <span class="unit">▼</span>
              </picker>
            </div>
          </div>
          <div class="panel-supplier">
            <div class="name">
              <span style="color: red;">*</span>
              {{local.buyArea}}
            </div>
            <div class="page" style="border-bottom: 2rpx solid;">
              <picker
                class="weui-btn"
                @change="changeBuyArea"
                :range="buyAreaList"
                :value="buyAreaPickerIndex"
                range-key="buyAreaName"
              >
                <input
                  type="default"
                  v-model="objEdit.buyAreaName"
                  disabled
                  :placeholder="local.peleaseEnter"
                />
                <span class="unit">▼</span>
              </picker>
            </div>
          </div>
          <div class="panel-ware">
            <div class="name">
              <span style="color: red;">*</span>
              {{local.warehouseIn}}：
            </div>
            <div class="page" style="border-bottom: 2rpx solid;">
              <picker
                class="weui-btn"
                @change="PickerWarehouseChange"
                :index="indexWarePicker"
                :range="arrayWarehouse"
                :range-key="'warehouseName'"
              >
                <input
                  type="default"
                  disabled
                  v-model="objEdit.warehouseName"
                  :placeholder="local.option"
                />
                <span class="unit">▼</span>
              </picker>
            </div>
          </div>
          <div class="panel-goods">
            <div class="name">{{local.goodsName}}：</div>
            <div class="names-goods">{{objEdit.goodsName}}</div>
          </div>
        </div>
      </div>
      <div class="select-photo">
        <div class="a name">
          <span style="color: red;">*</span>
          {{local.photosBeforeAcceptance}}
        </div>
        <div class="b">
          <div class="page">
            <div class="weui-uploader__bd">
              <div class="weui-uploader__files" id="uploaderFiles">
                <block v-for="(ite, index) in objEdit.beginPicUrlList" :key="index">
                  <div
                    class="weui-uploader__file"
                    @click="predivImage"
                    :id="ite"
                    :data-urls="objEdit.beginPicUrlList"
                  >
                    <img class="weui-uploader__img" :src="Shop + ite" mode="aspectFill" />
                    <div
                      style="color: #DE6E7C;display: flex;justify-content: center;font-size: 26rpx;"
                      @click="deleteImg(index,'beginPic')"
                    >{{local.deletesingle}}</div>
                  </div>
                </block>
              </div>
              <div class="weui-uploader__input-box">
                <div
                  class="weui-uploader__input"
                  @click="imageUpload(objEdit.beginPicUrlList,'beginPic')"
                ></div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="stock-detail-panel">
        <div class="stock-detail-belt">
          <span class="name">
            <span style="color: red;width: 2rpx;">*</span>
            {{local.beltType}}：
          </span>
          <div class style="border-bottom: 2rpx solid;">
            <picker
              class="weui-btn"
              mode="selector"
              @change="PickerBeltChange"
              :index="indexBeltPicker"
              :range="arrayBelt"
              :range-key="'dictLabel'"
              disabled
            >
              <input type="default" disabled v-model="beltType" :placeholder="local.option" />
              <span class="unit">▼</span>
            </picker>
          </div>
        </div>
        <div class="msg-detail-thickness" v-if="objEdit.beltType=='4'">
          <span class="name">
            <span style="color: red;width: 2rpx;">*</span>
            {{local.beltTypeName}}：
          </span>
          <div class style="border-bottom: 2rpx solid;">
            <input v-model="objEdit.beltTypeName" :placeholder="local.peleaseEnter" />
          </div>
        </div>
        <div class="msg-detail-grade">
          <span class="name">
            <span style="color: red;width: 2rpx;">*</span>
            {{local.grade}}：
          </span>
          <div class style="border-bottom: 2rpx solid;">
            <picker
              class="weui-btn"
              @change="PickerLevelChange"
              :value="indexLevelPicker"
              :range="arrayLevel"
              :range-key="'dictLabel'"
              disabled
            >
              <input type="default" disabled v-model="goodsLevel" :placeholder="local.option" />
              <span class="unit">▼</span>
            </picker>
          </div>
        </div>
        <div class="msg-detail-thickness">
          <span class="name">
            <span style="color: red;width: 2rpx;">*</span>
            {{local.thickness}}：
          </span>
          <div class style="border-bottom: 2rpx solid;">
            <input type="digit" v-model="objEdit.sizeHeight" :placeholder="local.peleaseEnter" />
            <span class="unit">MM</span>
          </div>
        </div>
        <div class="msg-detail-width">
          <span class="name">
            <span style="color: red;width: 2rpx;">*</span>
            {{local.width}}：
          </span>
          <div class style="border-bottom: 2rpx solid;">
            <input type="digit" v-model="objEdit.sizeWidth" :placeholder="local.peleaseEnter" />
            <span class="unit">MM</span>
          </div>
        </div>
        <div class="msg-detail-long">
          <span class="name">
            <span style="color: red;width: 2rpx;">*</span>
            {{local.length}}：
          </span>
          <div class style="border-bottom: 2rpx solid;">
            <input type="digit" v-model="objEdit.sizeLong" :placeholder="local.peleaseEnter" />
            <span class="unit" style="right: 16%;text-align: left;width: 5%;">M</span>
            <picker
              style="width: 10%;font-size: 38rpx;"
              disabled
              class="weui-btn"
              @change="PickerSymbolChange"
              :value="indexSymbolPicker"
              :range="arraySymbol"
            >
              <input type="default" v-model="objEdit.semiology" disabled />
            </picker>
          </div>
        </div>
        <div class="msg-detail-long">
          <span class="name">
            <span style="color: red;width: 2rpx;">*</span>
            {{local.weight}}：
          </span>
          <div class style="border-bottom: 2rpx solid;">
            <input type="digit" v-model="objEdit.weight" :placeholder="local.peleaseEnter" />
            <span class="unit">T</span>
          </div>
        </div>
        <div class="msg-detail-grade">
          <span class="name">{{local.frameType}}：</span>
          <div class style="border-bottom: 2rpx solid;">
            <picker
              class="weui-btn"
              @change="PickerFrameTypeChange"
              :value="indexFrameTypePicker"
              :range="arrayFrameType"
              :range-key="'dictLabel'"
            >
              <input type="default" v-model="frameTypeText" :placeholder="local.option" />
              <span class="unit">▼</span>
            </picker>
          </div>
        </div>
        <div class="msg-detail-grade" v-if="indexFrameTypePicker == 0">
          <span class="name">{{local.hub}}：</span>
          <div class style="border-bottom: 2rpx solid;">
            <picker
              class="weui-btn"
              @change="PickerHubChange"
              :value="indexHubPicker"
              :range="arrayHub"
              :range-key="'dictLabel'"
            >
              <input type="default" v-model="hubText" disabled :placeholder="local.option" />
              <span class="unit">▼</span>
            </picker>
          </div>
        </div>
        <!-- hub选择其他（indexHubPicker=2），则出现hub 备注-->
        <div class="msg-detail-long" v-if="indexHubPicker == 2">
          <span class="name">{{local.hubName}}：</span>
          <div class style="border-bottom: 2rpx solid;">
            <input type="text" v-model="objEdit.hubName" :placeholder="local.peleaseEnter" />
          </div>
        </div>
        <div class="msg-detail-grade" v-if="indexFrameTypePicker == 1">
          <span class="name">{{local.steelReel}}：</span>
          <div class style="border-bottom: 2rpx solid;">
            <picker
              class="weui-btn"
              @change="PickerSteelReelChange"
              :value="indexSteelReelPicker"
              :range="arraySteelReel"
              :range-key="'dictLabel'"
            >
              <input type="default" v-model="steelReelText" disabled :placeholder="local.option" />
              <span class="unit">▼</span>
            </picker>
          </div>
        </div>
        <!-- steelReel选择其他（indexSteelReelPicker=4），则出现hub 备注-->
        <div class="msg-detail-long" v-if="indexSteelReelPicker == 4">
          <span class="name">{{local.steelReelName}}：</span>
          <div class style="border-bottom: 2rpx solid;">
            <input type="text" v-model="objEdit.steelReelName" :placeholder="local.peleaseEnter" />
          </div>
        </div>
      </div>

      <div class="stock-detail-panel">
        <div class="msg-detail-long">
          <span class="name" style="width: 200rpx;">{{local.weighbridgeTerminalNo}}：</span>
          <div class style="border-bottom: 2rpx solid;width: auto;flex: 1;">
            <input v-model="objEdit.weightBridgePier" :placeholder="local.peleaseEnter" />
          </div>
        </div>
        <div class="msg-detail-long">
          <span class="name" style="width: 200rpx;">{{local.supplierInvoiceNumber}}：</span>
          <div class style="border-bottom: 2rpx solid;width: auto;flex: 1;">
            <input v-model="objEdit.supplierInvoice" :placeholder="local.peleaseEnter" />
          </div>
        </div>
        <div class="msg-detail-long">
          <div class="name jt_flex_row_right" style="width:190rpx">{{local.invoiceDate}}：</div>
          <!--            <div class="names-goods">{{saveObj.invoiceDate}}</div>-->
          <picker
            style="flex:1;"
            class="weui-btn"
            mode="date"
            :value="objEdit.invoiceDate"
            start="1999-01-01"
            end="2099-01-01"
            @change="TimeChange"
          >
            <input
              style="border-bottom: 2rpx solid;width: auto;flex: 1;"
              v-model="invoiceDateFormat"
              :placeholder="local.peleaseEnter"
              disabled
            />
          </picker>
        </div>
      </div>
      <div class="select-photo">
        <div class="a name">
          <span style="color: red;">*</span>
          {{local.photosAfterAcceptance}}
        </div>
        <div class="b">
          <div class="page">
            <div class="weui-uploader__bd">
              <div class="weui-uploader__files" id="uploaderFiles">
                <block v-for="(item, index) in files" :key="index">
                  <div
                    class="weui-uploader__file"
                    @click="predivImage"
                    :id="item"
                    :data-urls="files"
                  >
                    <img class="weui-uploader__img" :src="item" mode="aspectFill" />
                    <div
                      style="color: #DE6E7C;display: flex;justify-content: center;font-size: 26rpx;"
                      @click="deleteImg(index,'endPic')"
                    >{{local.deletesingle}}</div>
                  </div>
                </block>
              </div>
              <div class="weui-uploader__input-box">
                <div class="weui-uploader__input" @click="imageUpload(files,'endPic')"></div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="remark">
        <div>{{local.remark1}}:</div>
        <textarea
          v-model="objEdit.remark"
          style="height: 100rpx;max-width: 879rpx;resize: none;padding-left: 18rpx;"
        ></textarea>
      </div>
      <div class="remark">
        <div>{{local.remark2}}:</div>
        <textarea
          v-model="objEdit.remark2"
          style="height: 100rpx;max-width: 879rpx;resize: none;padding-left: 18rpx;"
        ></textarea>
      </div>
      <div class="bottom-bar">
        <div
          class="save-draft"
          @click="editBtnAgain"
        >{{local.submitAndContinueToCreateNewWarehouseEntry}}</div>
        <button class="confirm" style="font-size: 26rpx;" @click="editBtn">{{local.submitNew}}</button>
      </div>
    </div>
  </div>
</template>

<script>
// import { formatDate } from '@/utils/index'
import card from "@/components/card"
import headerBar from "@/components/headerBar"
import home from "@/api/home"
import Shop from "../../../../config/shop"
import { throttle } from "@/utils/throttle"
import { previewImage, dictMatching } from "@/utils/index"
var a
export default {
  components: {
    card,
    headerBar,
  },
  computed: {
    invoiceDateFormat(){
      const {invoiceDate} = this.objEdit
      return invoiceDate ? wx.$timeFormat(invoiceDate) : ''//new Date(invoiceDate).$format('dd/MM/yyyy') :''    
    },
  },
  onShow() {
    this.initLang()
    if (a) {
      a = false
      return
    } else {
      this.fromPrevPageData()
    }
  },
  onLoad(options) {
    this.initLang()
    if (options.page == "1") {
      // 如果不是列表页面进来的话，要进行从storage里面取数据
      this.fromPrevPageData()
    } else {
      // 如果是列表页面进入的话,是已审核状态，不需要任何操作
      this.id = options.id
      this.getInStockListId()
    }
    this.getSupplierList()
    this.getWarehouseList()
    this.pdt = this.globalData.CustomBar
  },
  methods: {
    TimeChange (e) {
      this.objEdit.invoiceDate = e.mp.detail.value
    },
    initLang(){
      this.local = wx.getStorageSync('local')
      this.buyAreaList = wx.getStorageSync('buyAreaList') || []
    },
    fromPrevPageData() {
      this.objEdit = wx.getStorageSync("stockInObj")
      this.objEdit.createTime = ""
      this.objEdit.endPicUrl = ''
      this.objEdit.endPicUrlList = []
      this.initEditData()
    },
    initEditData() {
      //初始化
      const {hub, hubName, steelReel, steelReelName, frameType} = this.objEdit
      this.objEdit.beginPicUrlList = this.objEdit.beginPicUrlList
      this.goodsLevel = dictMatching(
        wx.getStorageSync("goodsLevel"),
        this.objEdit.goodsLevel
      )
      this.beltType = dictMatching(
        wx.getStorageSync("beltType"),
        this.objEdit.beltType
      )
      this.hubText = hub == ''?'':dictMatching(wx.getStorageSync("hubType"),hub)
      this.frameTypeText = frameType == ''?'':dictMatching(wx.getStorageSync("frameType"),frameType)
      this.arrayFrameType.map((item, index) => {
        if (item.dictValue == frameType) {
          this.indexFrameTypePicker = index
        }
     })
      this.steelReelText = steelReel == ''? '':dictMatching(wx.getStorageSync("steelReel"),steelReel)
      this.arrayHub.map((item, index) => {
          this.indexHubPicker = item.dictValue == hub ? index:null
      })
      this.arraySteelReel.map((item, index) => {
          this.indexSteelReelPicker = item.dictValue == steelReel ? index: null
     })
    },
    resetData() {
      this.objEdit = {}
      this.indexHubPicker = 0
      this.indexSteelReelPicker = 0
      this.files = []
    },
    deleteImg(index, type) {
      if (type == "beginPic") {
        this.objEdit.beginPicUrlList.splice(index, 1)
      } else {
        this.objEdit.endPicUrlList.splice(index, 1)
      }
    },
    changeLan(val) {
      this.local = val
    },
    async editBtn(e) {
      if (this.files.length == 0) {
        wx.showToast({
          title: `${this.local.photosAfterAcceptance}字段未提交`,
          icon: "none",
          duration: 1000,
        })
        return
      }
      this.objEditNew = {
        buyAreaId:this.objEdit.buyAreaId,
        buyAreaName:this.objEdit.buyAreaName,
        invoiceDate: this.objEdit.invoiceDate,
        supplierId: this.objEdit.supplierId, //  供应商id
        supplierName: this.objEdit.supplierName,
        warehouseId: this.objEdit.warehouseId, // 仓库id
        warehouseName: this.objEdit.warehouseName,
        goodsName: this.objEdit.goodsName, //    商品名称
        beltType: this.objEdit.beltType, //   皮带类型
        beltTypeName: this.objEdit.beltTypeName, //   皮带类型
        goodsLevel: this.objEdit.goodsLevel, //   等级
        sizeHeight: this.objEdit.sizeHeight, //   厚度
        sizeWidth: this.objEdit.sizeWidth, //   宽度
        sizeLong: this.objEdit.sizeLong, //   长度
        weight: this.objEdit.weight, //   净重
        hub: this.objEdit.hub,
        frameType: this.objEdit.frameType,
        steelReel: this.objEdit.steelReel,
        hubName: this.objEdit.hubName,
        steelReelName: this.objEdit.steelReelName,
        // totalWeight: this.objEdit.totalWeight, //  总重
        remark: this.objEdit.remark, //  备注
        remark2: this.objEdit.remark2, //  备注2
        beginPicUrl: this.objEdit.beginPicUrlList.join(), // 验收前照片
        endPicUrl: this.objEdit.endPicUrlList.join(), // 验收后前照片
        status: 'SAVE',
        semiology: this.objEdit.semiology,
        weightBridgePier:
          this.objEdit.weightBridgePier == undefined
            ? ""
            : this.objEdit.weightBridgePier,
        supplierInvoice:
          this.objEdit.supplierInvoice == undefined
            ? ""
            : this.objEdit.supplierInvoice,
        invoiceDate: this.objEdit.invoiceDate == undefined ? "":this.objEdit.invoiceDate
      }
      wx.showLoading({
        title: `${this.local.jumping}`,
      })
      this.gotoPage(`/packageA/pages/purchaseReceipt/index`)
    },
    async editBtnAgain() {
      if (this.files.length == 0) {
        wx.showToast({
          title: `${this.local.photosAfterAcceptance}${this.local.required}`,
          icon: "none",
          duration: 1000,
        })
        return
      }
      this.objEditNew = {
        invoiceDate: this.objEdit.invoiceDate,
        supplierId: this.objEdit.supplierId, //  供应商id
        supplierName: this.objEdit.supplierName,
        warehouseId: this.objEdit.warehouseId, // 仓库id
        warehouseName: this.objEdit.warehouseName,
        goodsName: this.objEdit.goodsName, //    商品名称
        beltType: this.objEdit.beltType, //   皮带类型
        beltTypeName: this.objEdit.beltTypeName, //   皮带类型
        goodsLevel: this.objEdit.goodsLevel, //   等级
        sizeHeight: this.objEdit.sizeHeight, //   厚度
        sizeWidth: this.objEdit.sizeWidth, //   宽度
        sizeLong: this.objEdit.sizeLong, //   长度
        weight: this.objEdit.weight, //   净重
        hub: this.objEdit.hub,
        steelReel: this.objEdit.steelReel,
        hubName: this.objEdit.hubName,
        steelReelName: this.objEdit.steelReelName,
        frameType: this.objEdit.frameType,
        // totalWeight: this.objEdit.totalWeight, //  总重
        remark: this.objEdit.remark, //  备注
        remark2: this.objEdit.remark2, //  备注2
        beginPicUrl: this.objEdit.beginPicUrlList.join(), // 验收前照片
        endPicUrl: this.objEdit.endPicUrlList.join(), // 验收后前照片
        status: 'SAVE',
        weightBridgePier: this.objEdit.weightBridgePier,
        supplierInvoice: this.objEdit.supplierInvoice,
        semiology: this.objEdit.semiology
      }
      wx.showLoading({
        title: `${this.local.jumping}`,
      })
      this.gotoAddPage()
    },
    gotoAddPage: throttle(
      0,
      false,
      function() {
        this._addFunc()
      },
      false
    ),
    gotoPage: throttle(
      0,
      false,
      function(url) {
        this._func(url)
      },
      false
    ),
    //保存并新增
    _addFunc(){
      home.addInStock(this.objEditNew)
            .then(data => {
              if (data.code !== 0) {
                wx.showToast({
                  title: data.msg,
                  duration: 2000,
                  icon: "none",
                })
                return
              }
              this.files = []
              wx.hideLoading()
              wx.reLaunch({
                url: `../../pages/addStock/index`,
              })
              wx.hideLoading()
            })
            .catch(err => {
              wx.showToast({
                title: err,
                duration: 2000,
                icon: "none",
              })
              wx.hideLoading()
            })
    },
    //提交
    _func(url) {
      home
        .addInStock(this.objEditNew)
        .then(data => {
          if (data.code !== 0) {
            wx.showToast({
              title: data.msg,
              duration: 2000,
              icon: "none",
            })
            return
          }
          this.resetData()
          wx.navigateTo({
            url: url,
          })
          wx.hideLoading()
        })
        .catch(err => {
          wx.hideLoading()
          wx.showToast({
            title: err,
            duration: 2000,
            icon: "none",
          })
        })
    },
    async getGoodsName(supplierName) {
      const data = await home.getGoodsName({ supplierName: supplierName })
      this.objEdit.goodsName = data.msg
    },
    async getSupplierList() {
      const { rows } = await home.getSupplierList()
      this.array = rows
    },
    async getWarehouseList() {
      const { rows } = await home.getWarehouseList()
      this.arrayWarehouse = rows
    },
    async getInStockListId() {
      const data = await home.getInStockListId({ id: this.id })
      this.objEdit = data
      this.objEdit.createTime = this.objEdit.createTime.substring(0, 10)
      this.objEdit.endPicUrlList = this.objEdit.endPicUrl?[]:this.objEdit.endPicUrl.split(',')
      this.initEditData()
    },
    imageUpload(list,type) {
      a = true
      let _this = this
      //图片上传方法
      wx.chooseImage({
        sizeType: ["original", "compressed"], // 可以指定是原图还是压缩图，默认二者都有
        sourceType: ["album", "camera"], // 可以指定来源是相册还是相机，默认二者都有
        success: res => {
          // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
          //imgList.concat(res.tempFilePaths)
          if(type == 'endPic'){
            _this.files = _this.files.concat(res.tempFilePaths)
          }
          res.tempFilePaths.map((item, index) => {
            wx
              .uploadFile({
                url: `${Shop.BASE_URL}applet/buy/storage/common/upload`,
                filePath: item, // chooseImage上传的图片
                name: "file", // 需要传给后台的图片字段名称
                formData: item, // 需要传给后台的其他表单数据
                header: {
                  Authorization: wx.getStorageSync("token"),
                },
                success: res => {
                  if (res.statusCode == 200) {
                    let { code, url, msg } = JSON.parse(res.data)
                    if (code == 0) {
                      list.push(url)
                      if(type == 'endPic'){
                          _this.objEdit.endPicUrlList.push(url)
                      }
                      _this.$forceUpdate()
                      // type == "beginPic"
                      //   ? _this.objEdit.beginPicUrlList.push(url)
                      //   :
                    } else {
                      wx.showToast({
                        title: msg,
                        duration: 4000,
                        icon: "none",
                      })
                    }
                  } else {
                    wx.showToast({
                      title: _this.local.uploadFail,
                      duration: 4000,
                      icon: "none",
                    })
                  }
                },
              })
          })
        },
        fail: function() {},
        complete: function() {},
      })
    },
     PickerFrameTypeChange(e){
      this.indexFrameTypePicker = e.mp.detail.value
      this.frameTypeText = this.arrayFrameType[e.mp.detail.value].dictLabel
      this.objEdit.frameType = this.arrayFrameType[e.mp.detail.value].dictValue
      //切换框架类型时，清空 hub/轮轴
      this.indexHubPicker = null
      this.indexSteelReelPicker = null
      this.hubText = ''
      this.steelReelText = ''
      this.objEdit.hub = ''
      this.objEdit.hubName = ''
      this.objEdit.steelReelName = ''
      this.objEdit.steelReel = ''
      this.saveObj.hub = ''
      this.saveObj.hubName = ''
      this.saveObj.steelReelName = ''
      this.saveObj.steelReel = ''

    },
     PickerHubChange(e){
      this.indexHubPicker = e.mp.detail.value
      this.hubText = this.arrayHub[e.mp.detail.value].dictLabel
      this.objEdit.hub = this.arrayHub[e.mp.detail.value].dictValue
    },
    PickerSteelReelChange(e){
      this.indexSteelReelPicker = e.mp.detail.value
      this.steelReelText = this.arraySteelReel[e.mp.detail.value].dictLabel
      this.objEdit.steelReel = this.arraySteelReel[e.mp.detail.value].dictValue
    },
    PickerSymbolChange (e) {
      this.indexSymbolPicker = e.mp.detail.value
      this.objEdit.semiology = this.arraySymbol[e.mp.detail.value]
    },
    PickerChange(e) {
      this.indexPicker = e.mp.detail.value
      this.objEdit.supplierName = this.array[e.mp.detail.value].supplierName
      this.objEdit.supplierId = this.array[e.mp.detail.value].supplierId
      this.getGoodsName(this.objEdit.supplierName)
    },
    PickerWarehouseChange(e) {
      this.indexWarePicker = e.mp.detail.value
      this.objEdit.warehouseName = this.arrayWarehouse[
        e.mp.detail.value
      ].warehouseName
      this.objEdit.warehouseId = this.arrayWarehouse[
        e.mp.detail.value
      ].warehouseId
    },
    PickerBeltChange(e) {
      this.indexBeltPicker = e.mp.detail.value
      this.objEdit.beltType = this.arrayBelt[e.mp.detail.value].dictValue
    },
    PickerLevelChange(e) {
      this.indexLevelPicker = e.mp.detail.value
      this.objEdit.goodsLevel = this.arrayLevel[e.mp.detail.value].dictValue
    },
    routerToUrl(url) {
      wx.navigateTo({
        url,
      })
    },

    changeBuyArea(e){
      const {value} = e.target
      const {buyAreaName,buyAreaId} = this.buyAreaList[value]
      console.log(buyAreaId)
      this.buyAreaPickerIndex = value
      this.objEdit.buyAreaName = buyAreaName
      this.objEdit.buyAreaId = buyAreaId
    },
    predivImage(e) {
      previewImage(e)
    },
  },
  data() {
    return {
      Shop: Shop.IMG_URL,
      endPicUrl: [],
      confirmDisable: true,
      beltType: 0,
      goodsLevel: 0,
      hubText: '',
      steelReelText:'',
      frameTypeText: '',
      local: wx.getStorageSync("local"),
      pdt: 66,
      // objEditNew: [],
      // objEdit: [],
      objEdit: {
        beginPicUrlList: [],
        endPicUrlList: [],
      },
      objEditNew: {},
      indexPicker: 1,
      indexSymbolPicker: 0,
      indexBeltPicker: 1,
      indexLevelPicker: 1,
      indexWarePicker: 1,
      indexHubPicker: 0,
      indexSteelReelPicker: 0,
      indexFrameTypePicker: null,
      arraySymbol: ['>=', '<='],
      array: ["美国", "中国", "阿拉伯", "非洲"],
      arrayWarehouse: ["1号仓库", "2号仓库", "3号仓库", "4号仓库"],
      arrayLevel: ["A", "B", "C", "D", "E"],
      arrayBelt: ["122", "128", "125", "126", "127"],
      arraySteelReel: wx.getStorageSync('steelReel') || [],
      arrayHub: wx.getStorageSync('hubType') || [],
      arrayFrameType: wx.getStorageSync('frameType') || [],
      id: "",
      files: [],
      logs: [],
      fileList: [],
      buyAreaList:[],
      buyAreaPickerIndex:[]
    }
  },
}
</script>

<style scoped lang="scss">
@import 'index';
.log-list {
  display: flex;
  flex-direction: column;
  padding: 40rpx;
}

.log-item {
  margin: 10rpx;
}
</style>
